import redis
from Config.config import *

redis_client = redis.Redis(Redis_HOST, password=Redis_PASSWORD, decode_responses=True, db=Redis_DB)
# redis_client = redis.Redis("192.168.66.54", db=0)


#   任务队列上传方法
def push_queue(redis_key, value):
    redis_client.sadd(redis_key, value)


def pop_queue(redis_key):
    a = redis_client.spop(redis_key)
    return a


def estimate_queue(key):
    # 判断队列是否消费完。消费完返回True继续生成队列，没消费完返回False不作处理
    if redis_client.exists(key):
        return True
    else:
        return False


if __name__ == '__main__':
    a = pop_queue("zhongwenqikan:cma:cma_article_url")
    if not a:
        print(1)
